package com.haitai.gas.integration.poi;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.haitai.gas.integration.poi.policy.index.IndexRenderPolicy1;
import org.ddr.poi.html.HtmlRenderPolicy;

import java.io.IOException;
import java.util.HashMap;

public class PoiMain {

    public static void main(String[] args11) {
//        Configure config = Configure.builder()
//                .bind("index", new HelloPolicy())
//                .bind("statement", new HtmlPolicy())
//                .bind("survey", new HelloPolicy())
//                .bind("content", new HelloPolicy())
//                .bind("evaluate", new HelloPolicy())
//                .build();
        Configure config = Configure.builder()
                .bind("index", new IndexRenderPolicy1())
                .bind("statement", new HtmlRenderPolicy())
                .bind("survey", new IndexRenderPolicy1())
                .bind("content", new IndexRenderPolicy1())
                .bind("evaluate", new IndexRenderPolicy1())
                .build();
        String markdown = "<p>备注：报告骑缝章已取消。</p>\n" +
                "<p>1.报告无本公司检测专用章无效；</p>\n" +
                "<p>2.本报告无主检测人、审核人、批准人签字无效；</p>\n" +
                "<p>3.本报告涂改无效；</p>\n" +
                "<p>4.未经本公司书面批准，不得复制报告；</p>\n" +
                "<p>8.本检测报告只对检测时的状态和性能复制。</p>";
        HashMap<String, Object> args = new HashMap<String, Object>();

        args.put("index", "index");
        args.put("statement", markdown);
        args.put("survey", "index");
        args.put("content", "content");
        args.put("evaluate", "evaluate");

        try {
            XWPFTemplate
                    .compile("E:\\template-test.docx", config)
                    .render(args)
                    .writeToFile("E:\\template-test-out.docx");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
